iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 13
0
Modern Web

用30days 了解web系列 第 13

(day 13) Making commit and reset commit with git

  • 分享至 

  • xImage
  •  

today's article still about git and today we will discuss more making commit and reset commit with git. and the git platform I'll be using is gitlab.

Commit
before making a commit, we need to make initialize on a running project by simply run the following script:
git init
before going to commit. I'm going to explain what is commit first, The "commit" command is used to save your changes to the local repository.
moving on with git commit. to commit a change, just simply run this three script:

$ git status
$ git add --filename
git commit -m "your message"
git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by git.

git add command adds new or changed files in your working directory to the Git staging area.

git commit -m "Add existing file" # Commits the tracked changes and prepares them to be pushed to a remote repository.

Undo Commit
https://ithelp.ithome.com.tw/upload/images/20200926/20129609Ge3l4G9dEZ.png
git has three existing methods to undo commit or reset commit, there are checkout, revert, reset.

Let's say right now we are in the fifth commit like the image above, if someone wish to go back to the third commit, we may use checkout, revert, or reset depending on the situation.

git checkout if you wish to see your codes on third commit state, use checkout.

git revert command is a forward-moving undo operation that offers a safe method of undoing changes.

git reset when git reset is executed you, your Head will move back to the third commit and the remaining four and fifth commit will be removed as well. to perform reset you need to be considerate.


上一篇
(day 12) Introduction to Basic GIT
下一篇
(day 14) Database normalization
系列文
用30days 了解web30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言